﻿using System;
using System.Linq;
using System.Text;
using CookComputing.XmlRpc;

namespace VH.SharePoint.Api.MetaWeblog
{
    [XmlRpcMissingMapping(MappingAction.Ignore)]
    public class Post
    {
        [XmlRpcMember("title",Description = "Post title")]
        public String Title { get; set; }
        [XmlRpcMember("description", Description = "Post content")]
        public String Description { get; set; }
        [XmlRpcMember("link", Description = "Post absolute URL")]
        public String Url { get; set; }
        [XmlRpcMember("post_type", Description = "\"post\" or \"page\"")]
        public String Type { get; set; }
        [XmlRpcMember("categories", Description = "Names of categories assigned to the post")]
        public String[] Categories { get; set; }
      
        #region Movable Type Extension

        [XmlRpcMember("mt_keywords", Description = "Names of tags assigned to the post")]
        public String Keywords { get; set; }
        [XmlRpcMember("mt_excerpt", Description = "Not used")]
        public String Excerpt { get; set; }
        [XmlRpcMember("mt_text_more", Description = "Post \"Read More\" text")]
        public String TextMore { get; set; }
        [XmlRpcMember("mt_allow_comments", Description = "Post allow comments. \"open\" or \"closed\"")]
        public String AllowComments { get; set; }
        [XmlRpcMember("mt_allow_pings", Description = "Post allow pingsback. \"open\" or \"closed\"")]
        public String AllowPings { get; set; }

        #endregion
     
        #region Wordpress Extension

        [XmlRpcMember("postid", Description = "Post Identifier")]
        public Int32 Id { get; set; }
        
        [XmlRpcMember("dateCreated", Description = "Post date")]
        public DateTime Created { get; set; }
        [XmlRpcMember("date_created_gmt", Description = "Post date GMT")]
        public DateTime CreatedGmt
        {
            get { return Created.ToUniversalTime(); }
            set { }
        }
        [XmlRpcMember("date_modified", Description = "Post date")]
        public DateTime Modified { get; set; }
        [XmlRpcMember("date_modified_gmt", Description = "Post date GMT")]
        public DateTime ModifiedGmt
        {
            get { return Modified.ToUniversalTime(); }
            set { }
        }
        [XmlRpcMember("permaLink", Description = "Post absolute URL, equivalent to link")]
        public String PermaLink { get; set; }
        [XmlRpcMember("wp_more_text", Description = "Post \"Read More\" text")]
        public String TextMore2
        {
            get { return TextMore; }
            set { }
        }
        [XmlRpcMember("wp_slug", Description = "")]
        public String Slug { get; set; }
        [XmlRpcMember("wp_password", Description = "")]
        public String Password { get; set; }
        [XmlRpcMember("wp_author_id", Description = "Author identifier")]
        public String AuthorId { get; set; }
        [XmlRpcMember("wp_author_display_name", Description = "Author display name")]
        public String AuthorDisplayName { get; set; }
        [XmlRpcMember("post_status", Description = "Post status")]
        public String Status { get; set; }
        [XmlRpcMember("wp_post_format", Description = "Post format")]
        public String Format { get; set; }
        [XmlRpcMember("sticky", Description = "")]
        public Boolean Sticky { get; set; }
        [XmlRpcMember("custom_fields", Description = "")]
        public Field[] CustomFields { get; set; }

        #endregion

        [XmlRpcMember("enclosure", Description = "Only set if post has an enclosure.")]
        public Enclosure Enclosure { get; set; }

        [XmlRpcMember("publish", Description = "Is published")]
        public Boolean Published { get; set; }
    }
}
